//
//  BubbleStack.swift
//  demo01
//
//  Created by babybus on 2025/7/7.
//
import Foundation
import UIKit
import SnapKit
import Alamofire

class BubbleStack:UIStackView{
    private var bubbleLable:UILabel!
    private var bubbleButton:UIButton!
    override init(frame: CGRect) {
        super.init(frame: frame)
        attributeInit()
        setupUI()
    }
    required init(coder: NSCoder) {
        fatalError("init(coder:NSCoder) -- fatalError")
    }
    //属性设置
    func attributeInit(){
        axis = .vertical
        alignment = .fill
        distribution = .fill
    }
    func configure(img:String,number:Int,title:String){
        bubbleButton.setBackgroundImage(UIImage(named: img) ?? UIImage(named: "redBubble"), for: .normal)
        bubbleButton.setTitle("+" + String(number), for: .normal)
        bubbleButton.setTitleColor(UIColor(red: 219/255, green: 79/255, blue: 52/255, alpha: 1.0), for: .normal)
        bubbleButton.titleLabel?.textAlignment = .center
    
        bubbleLable.text = title
        bubbleLable.textColor = .white
        bubbleLable.textAlignment = .center
    }
    //布局
    func setupUI(){
        bubbleLable = UILabel()
        bubbleButton = UIButton()
        
        bubbleLable.text = "textLabel"
        
        self.addArrangedSubview(bubbleButton)
        self.addArrangedSubview(bubbleLable)
        
        bubbleButton.snp.makeConstraints { make in
            make.width.equalToSuperview()
            make.height.equalTo(60)
        }
        bubbleLable.snp.makeConstraints { make in
            make.width.equalToSuperview()
            make.height.equalTo(15)
        }
    }
}
